﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Production.DomainLib.AggregatesModel.TechnologyAggregate;

namespace Production.InfrastructureLib.EntityConfigurations
{
    internal class TechnologyEntityTypeConfiguration : IEntityTypeConfiguration<Technology>
    {
        public void Configure(EntityTypeBuilder<Technology> builder)
        {
            builder.ToTable("MES_TECHNOLOGY");

            builder.HasKey(o => o.Id);

            builder.Ignore(b => b.DomainEvents);

            var navigation = builder.Metadata.FindNavigation(nameof(Technology.TechnologyDetails));

            // DDD Patterns comment:
            //Set as field (New since EF 1.1) to access the OrderItem collection property through its field
            navigation?.SetPropertyAccessMode(PropertyAccessMode.Field);
        }
    }
}
